function allesin1()
% This is a test file I think (that Ralph created as an example of how I
% could set up a file like this), PlotResultscombP is the final
% version/actual version used. 
% plot alle periodes (4 verschillende lijnen) in 1 figure. 

load('Output.mat');

% Loop over periodes
   % Haal de data op met ResultsEP
   [D1 X1] = ResultsEP();
   [D2 X2] = ResultsEP();
   [D3 X3] = ResultsEP();
   [D4 X4] = ResultsEP();


%% Plotting   
% Roep bv een PlotElectrodePeriod (zie PlotResultsEP.m) aan met de data van
% alle periodes...
subplot(4,2,1);
hold on
plot(X1, D1(1,:));
plot(X2, D2(1,:));
plot(X3, D3(1,:));
plot(X4, D4(1,:));
ylabel N1
title (['Period ' num2str(period) ' - Electrode ' electrode]);
legend('Period 1','Period 2', 'Period 3', 'Period 4');

subplot(4,2,2);
hold on
plot(X1, D1(2,:));
plot(X2, D2(2,:));
plot(X3, D3(2,:));
plot(X4, D4(2,:));

subplot(4,2,3);
hold on
plot(X1, D1(3,:));
plot(X2, D2(3,:));
plot(X3, D3(3,:));
plot(X4, D4(3,:));
ylabel P1

subplot(4,2,4);
hold on
plot(X1, D1(4,:));
plot(X2, D2(4,:));
plot(X3, D3(4,:));
plot(X4, D4(4,:));

subplot(4,2,5);
hold on
plot(X1, D1(5,:));
plot(X2, D2(5,:));
plot(X3, D3(5,:));
plot(X4, D4(5,:));
ylabel N2

subplot(4,2,6);
hold on
plot(X1, D1(6,:));
plot(X2, D2(6,:));
plot(X3, D3(6,:));
plot(X4, D4(6,:));

subplot(4,2,7);
hold on
plot(X1, D1(7,:));
plot(X2, D2(7,:));
plot(X3, D3(7,:));
plot(X4, D4(7,:));
ylabel P2
xlabel 'latency'

subplot(4,2,8);
hold on
plot(X1, D1(8,:));
plot(X2, D2(8,:));
plot(X3, D3(8,:));
plot(X4, D4(8,:));
xlabel 'value'

end

%% Rest van de onzin
function PlotResultsByEP(subjectNrs, electrodes)

% skipnext = true;
disp(['====> Subjects:']);
for i = subjectNrs
    disp(['     ' output.subjects(i).Name]);
end
%     if skipnext; continue; end;
 for p=1:4 % assume there are 4 periods to loop over!
      for e=1:length(electrodes)
        electrode = electrodes{e};
   
        f = PlotResultsEP(output, subjectNrs, electrode, p);
        
        saveFigure(f, 'J:\PeakAnalysis\Results\allesin1', ['P' num2str(p) ' - ' electrode]);
        close(f);
      end
end
end